package com.mickey.service.Imp;

import com.mickey.dao.GoodsDao;
import com.mickey.domain.Goods;
import com.mickey.domain.MiaoshaGoods;
import com.mickey.service.GoodsService;
import com.mickey.vo.GoodsVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Desc:
 * @Author:czx
 * @CreateDate:2019/1/10 0010$ 14:48$
 */
@Service
public class GoodsServiceImp implements GoodsService {

    @Autowired
    GoodsDao goodsDao;

    @Override
    public List<GoodsVO> listGoodsVO() {
        return goodsDao.listGoodsVO();
    }

    @Override
    public GoodsVO getGoodsVOByGoodsId(long goodsId) {
        return goodsDao.getGoodsVOByGoodsId(goodsId);
    }

    @Override
    public boolean reduceStock(GoodsVO good) {
        MiaoshaGoods g = new MiaoshaGoods();
        g.setGoodsId(good.getId());
        int ret = goodsDao.reduceStock(g);
        return ret > 0;
    }
}
